package com.ruoyi.security.service.impl;

import java.util.List;
import com.ruoyi.common.core.utils.DateUtils;
import cn.hutool.core.util.IdUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.common.core.utils.SecurityUtils;
import com.ruoyi.security.mapper.AfSafetyMeetingMapper;
import com.ruoyi.security.domain.AfSafetyMeeting;
import com.ruoyi.security.service.IAfSafetyMeetingService;

/**
 * 安全会议Service业务层处理
 *
 * @author cjie
 * @date 2021-07-24
 */
@Service
public class AfSafetyMeetingServiceImpl implements IAfSafetyMeetingService {
    @Autowired
    private AfSafetyMeetingMapper afSafetyMeetingMapper;

    /**
     * 查询安全会议
     *
     * @param id 安全会议ID
     * @return 安全会议
     */
    @Override
    public AfSafetyMeeting selectAfSafetyMeetingById(String id) {
        return afSafetyMeetingMapper.selectAfSafetyMeetingById(id);
    }

    /**
     * 查询安全会议列表
     *
     * @param afSafetyMeeting 安全会议
     * @return 安全会议
     */
    @Override
    public List<AfSafetyMeeting> selectAfSafetyMeetingList(AfSafetyMeeting afSafetyMeeting) {
        return afSafetyMeetingMapper.selectAfSafetyMeetingList(afSafetyMeeting);
    }

    /**
     * 新增安全会议
     *
     * @param afSafetyMeeting 安全会议
     * @return 结果
     */
    @Override
    public int insertAfSafetyMeeting(AfSafetyMeeting afSafetyMeeting) {
        afSafetyMeeting.setId(IdUtil.getSnowflake(0, 0).nextIdStr());
        afSafetyMeeting.setCreateTime(DateUtils.getNowDate());
        afSafetyMeeting.setCreateBy(SecurityUtils.getUsername());
        return afSafetyMeetingMapper.insertAfSafetyMeeting(afSafetyMeeting);
    }

    /**
     * 修改安全会议
     *
     * @param afSafetyMeeting 安全会议
     * @return 结果
     */
    @Override
    public int updateAfSafetyMeeting(AfSafetyMeeting afSafetyMeeting) {
        afSafetyMeeting.setUpdateTime(DateUtils.getNowDate());
        afSafetyMeeting.setUpdateBy(SecurityUtils.getUsername());
        return afSafetyMeetingMapper.updateAfSafetyMeeting(afSafetyMeeting);
    }

    /**
     * 批量删除安全会议
     *
     * @param ids 需要删除的安全会议ID
     * @return 结果
     */
    @Override
    public int deleteAfSafetyMeetingByIds(String[] ids) {
        return afSafetyMeetingMapper.deleteAfSafetyMeetingByIds(ids);
    }

    /**
     * 删除安全会议信息
     *
     * @param id 安全会议ID
     * @return 结果
     */
    @Override
    public int deleteAfSafetyMeetingById(String id) {
        return afSafetyMeetingMapper.deleteAfSafetyMeetingById(id);
    }
}
